import { ControlVOBase } from '@/core/modules';
import { IContext, IParam } from '../../common';
import { IHttpResponse } from '../common';

/**
 * 部件服务接口
 *
 * @export
 * @interface ICtrlService
 */
export interface ICtrlService<T extends ControlVOBase | ControlVOBase[]> {
	/**
	 * 处理请求前数据
	 *
	 * @param {IContext} context
	 * @param {IParam} data
	 * @memberof ICtrlService
	 */
	handleRequestData(context: IContext, data: IParam): void;

	/**
	 * 处理请求后
	 *
	 * @param {IHttpResponse} response
	 * @param {IParam} [opts]
	 * @return {*}  {IHttpResponse}
	 * @memberof ICtrlService
	 */
	handleResponse(response: IHttpResponse, opts?: IParam): IHttpResponse;

	/**
	 * 创建VO模型
	 *
	 * @param {IParam} DO
	 * @param {string} [controlVoName] 多实体时需传入vo类名
	 * @return {*}  {T}
	 * @memberof ICtrlService
	 */
	newControlVO(DO: IParam, controlVoName?: string): T;

	/**
	 * 搜索
	 *
	 * @param {string} action
	 * @param {IParam} context
	 * @param {IParam} data
	 * @return {*}  {Promise<IHttpResponse>}
	 * @memberof ICtrlService
	 */
	search(action: string, context: IParam, data: IParam): Promise<IHttpResponse>;
}
